<%= form_for [refinery, :pods_admin, @pod] do |f| -%>
  <%= render '/refinery/admin/error_messages',
              :object => @pod,
              :include_object_name => true %>

  <%= hidden_field_tag 'pod[page_ids][]' %>

  <div class='field'>
    <%= f.label :pod_type -%>
    <%= f.select :pod_type, ::Refinery::Pods::Pod::POD_TYPES, {:include_blank => true} %>
  </div>

  <div class='field'>
    <%= f.label :name -%>
    <%= f.text_field :name, :class => 'larger widest'  -%>

  </div>
  
  <div class='field'>
    <div id='page-tabs' class='clearfix ui-tabs ui-widget ui-widget-content ui-corner-all'>
      <ul id='page_parts'>
        <% [:body].each_with_index do |part, part_index| %>
          <li class='ui-state-default<%= ' ui-state-active' if part_index == 0 %>'>
            <%= link_to t("#{part}", :scope => "activerecord.attributes.refinery/pods/pod", :default => part.to_s.titleize), "##{part}" %>
          </li>
        <% end %>
      </ul>
      <div id='page_part_editors'>
        <% [:body].each do |part| %>
          <div class='page_part' id='<%= part %>'>
            <%= f.text_area part, :rows => 20, :class => 'wymeditor widest' -%>
          </div>
        <% end %>
      </div>
    </div>

  </div>
  
  <div class='field'>
    <%= f.label :url -%>
    <%= f.text_field :url  -%>

  </div>
  
  <div class='field'>
    <%= f.label :image -%>
    <%= render '/refinery/admin/image_picker',
               :f => f,
               :field => :image_id,
               :image => @pod.image,
               :toggle_image_display => false %>

  </div>

  <div class='field'>
    <%= f.label :portfolio_entry_id, 'Gallery' -%>
    <%= f.collection_select :portfolio_entry_id, ::Refinery::Portfolio::Gallery.order(:title), :id , :title, {:prompt => "-- Please select when relevant --"}, {} -%>
  </div>

  <div class='field'>
    <%= f.label :video_id -%>
    <%= f.collection_select :video_id, ::Refinery::Videos::Video.order(:name), :id , :name, {:prompt => "-- Please select when relevant --"}, {} -%>
  </div>

  <div class="field">
    <%= f.label :pages %>
    <% ::Refinery::Page.all.each do |page| %>
      <div>
        <%= check_box_tag "pod[page_ids][]", page.id, @pod.pages.include?(page) %>
        <%= page.title %>
      </div>
    <% end %>
  </div>

  <%= render '/refinery/admin/form_actions', :f => f,
             :continue_editing => false,
             :delete_title => t('delete', :scope => 'refinery.pods.admin.pods.pod'),
             :delete_confirmation => t('message', :scope => 'refinery.admin.delete', :title => @pod.name) %>
<% end -%>
<% content_for :javascripts do %>
  <script>
    $(document).ready(function(){
      page_options.init(false, '', '');
    });
  </script>
<% end %>
